package homework.employee;

import java.util.*;

public class EmployeeTest {
    public static void main(String[] args) {
        LinkedList<Employee> list = new LinkedList<Employee>();
        list.add(new Employee(1,"张三",18,3000));
        list.add(new Employee(2,"李四",25,3500));
        list.add(new Employee(3,"王五",22,3200));
        //在李四前增加赵六
        list.add(1,new Employee(1,"赵六",20,3200));
        //删除王五
        list.removeLast();


        for (int i = 0 ,size=list.size(); i < size; i++) {
            Employee employee = (Employee)list.get(i);

            System.out.println(employee);
        }
        System.out.println("----------------------------------------");
        Iterator<Employee> it = list.listIterator();
        while (it.hasNext()){
            System.out.print(it.next()+"\n");
        }




    }

}



class Employee{
    int id;
    String name;
    int age;
    double wages;

    public Employee(int id, String name, int age, double wages) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.wages = wages;
    }



    @Override
    public String toString() {
        return "Employee{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", wages=" + wages +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Employee employee = (Employee) o;
        return id == employee.id &&
                age == employee.age &&
                Double.compare(employee.wages, wages) == 0 &&
                name.equals(employee.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, age, wages);
    }

    public Employee() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getWages() {
        return wages;
    }

    public void setWages(double wages) {
        this.wages = wages;
    }
}